<template>
	<view class="k-v-panel">
		<view class="k-v-panel-key" :style="keyStyle">{{label}}</view>
		<view class="k-v-panel-value">
			<view class="k-v-panel-content">
				<slot></slot>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			label: String,
			// 单位默认em
			labelWidth: [String, Number]
		},
		computed: {
			keyStyle() {
				if (this.labelWidth) {
					return {
						width: Number.isInteger(this.labelWidth) ? `${this.labelWidth}em` : this.labelWidth
					}
				}
				return {};
			}
		}
	}
</script>

<style lang="scss">
	.k-v-panel {
		box-sizing: border-box;
		display: flex;
		align-items: flex-start;
		// padding: 8px 10px;
    padding: 0;
		
		&-key {
			// margin-right: 10px;
			flex: none;
			width: 5em;
			text-align: right;
			line-height: 20px;
			color: #999;
		}
		
		&-value {
			flex: 1;
			position: relative;
			line-height: 20px;
		}
		
		&-content {
			display: flex;
			align-items: center;
			color: #333;
		}
	}
</style>